#ifndef GAME_INTERFACE_H_
#define GAME_INTERFACE_H_

#include "entityinterface.h"
#include "framescene.h"
#include "entityfactory.h"
#include "gamerules.h"
#include "luainterface.h"
#include "map.h"
#include "log.h"
#include "battlesystem.h"
#include "gamecamera.h"
#include "collisionsystem.h"
#include "shadersystem.h"

class CGameInterface : public CLuaInterface
{
	
	
private:
	
	CEntityFactory * m_pEntityFactory;
	
	CGameCamera * m_pGameCamera;
	
	CFrameScene * m_pFrameScene;
	
	CEntity * m_pPlayerEntity;
	
	CMap * m_pGameMap;
	
	CCollisionSystem * m_pCollisionSystem;
	CBattleSystem * m_pBattleSystem;
	CShaderSystem * m_pShaderSystem;
	
	std::string m_CurMap;
	std::string m_PreviousMap;
	std::string m_NextMap;
	
	bool m_bPlayerRefreshed;
	
	void Init();
	void CreateLuaHooks();
	void CreateLuaEntityHooks();

	
public:
	
	CGameInterface() : CLuaInterface()
	{
		
		Init();
		
	}

	inline void SetGameCamera( CGameCamera * c )
	{
		
		m_pGameCamera = c;
		
	}
	
	inline CGameCamera * GetGameCamera()
	{
		
		return m_pGameCamera;
		
	}
	
	inline bool PlayerRefreshed()
	{
		
		if( m_bPlayerRefreshed )
		{
			
			m_bPlayerRefreshed = false;
			return true;
			
		}
		
		return false;
		
	}
	
	bool ChangeMap();
	
	CEntity * CreateEntity();
	
	CEntity * GetPlayer();
	
	inline CMap * GetMap() 
	{
		
		return m_pGameMap;
		
	}
	
	inline CBattleSystem * BattleSystem()
	{
		
		return m_pBattleSystem;
		
	}
	
	inline CCollisionSystem * CollisionSystem()
	{
		
		return m_pCollisionSystem;
		
	}
	
	void InitShaders();
	void InitFontResources();
	
	void AddBattleEntity( int, std::string );
	
	inline const std::string & GetPreviousMapName()
	{
		
		return m_PreviousMap;
		
	}
	
	inline const std::string & GetCurMapName()
	{
		
		return m_CurMap;
		
	}
	
	inline void ScheduleLoadMap( std::string dir )
	{
		
		m_NextMap = dir;
		
	}
	
	void LoadMap( std::string );
	
	inline bool PlayerCreated()
	{
		
		return !( m_pPlayerEntity == NULL );
		
	}
	
	inline void SetEntityFactory( CEntityFactory * f )
	{
  
		m_pEntityFactory = f;
		m_pEntityFactory->SetFrameScene( m_pFrameScene );
 
	}
	
	inline CEntityFactory * GetEntityFactory()
	{
	
		return m_pEntityFactory;
		
	}
	
	void CreateSubSystems();
	
	inline CFrameScene * GetFrameScene()
	{
	
		
		return m_pFrameScene;
		
	}
	
	void RegisterLuaEngineHooks();
	
	void Think();
	
	void InitGameRules();
	
	virtual ~CGameInterface();
	


};

#endif
